home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / grafix.doc < prev    next >
Text File  |  1995-03-31  |  30KB  |  951 lines

  1. Here's the information that I promised in an earlier note regarding programming
  2. graphics on the HP 95LX.  Caveat Programmer.
  3.  
  4. Everett Kaser                   Hewlett-Packard Company
  5. ...hplabs!hp-pcd!everett        work: (503) 750-3569   Corvallis, Oregon
  6. everett%hpcvra@hplabs.hp.com    home: (503) 928-5259   Albany, Oregon
  7. ----------------------------- cut here --------------------------------------
  8.          __________________________________
  9.  
  10.     HP 95LX Low-level Graphics Support
  11.     __________________________________
  12.  
  13.     Copyright 1991 Hewlett-Packard Company
  14.     All rights reserved
  15.     (distributed with permission)
  16.     ____________
  17.     INTRODUCTION
  18.  
  19.     The package of low-level routines provided in the HP 95LX that are
  20.     available for use by applications programs support these functions:
  21.  
  22.          1) setting the display mode to alpha or graphics.
  23.                  2) setting a fill mask.
  24.          3) getting information about the current graphics settings.
  25.          4) setting a logical origin to which all other graphics
  26.             operations are relative.
  27.          5) setting a rectangular clip region.
  28.          6) drawing an outlined, solid-filled, or pattern-filled
  29.             rectangle.
  30.          7) drawing a line.
  31.          8) plotting a point.
  32.          9) moving the current pen location.
  33.         10) setting the current pen color.
  34.         11) setting the current replacement rule.
  35.         12) setting the current line-type.
  36.         13) reading the current color value of a point.
  37.         14) reading a rectangular image.
  38.         15) writing a rectangular image.
  39.         16) labeling text using the internal 6x8 font.
  40.  
  41.     All of the routines which plot to the display always obey the current
  42.     logical origin, clip region, pen color, replacement rule, and (where
  43.     appropriate) line-type and fill-mask.
  44.  
  45.     The pen color can be 0 or 1.
  46.  
  47.     The replacement rule can be one of FORCE, AND, OR, or XOR.  Writing
  48.     a rectangular image can optionally invert the image before applying
  49.     the specified replacement rule.  Writing an image is different from
  50.     all other plotting in that it uses an argument as the replacement
  51.     rule rather than the current replacement rule.
  52.  
  53.     The line-type is a 16-bit value whose bits are used repeatedly when
  54.     drawing a line or an outlined rectangle.
  55.  
  56.     The fill-mask is an 8-byte value which specifies an 8-bit by 8-bit
  57.     rectangular mask which is used repeatedly when drawing a pattern-filled
  58.     rectangle.
  59.          The general process to do graphics is:
  60.  
  61.         1) set the display mode to graphics
  62.         2) set the desired pen color, replacement rule, linetype,
  63.             fillmask, logical origin, and clip region, if different
  64.             than the default values set by the set-mode function.
  65.         3) perform the desired drawing using the attributes setup by
  66.             step 2).
  67.         4) repeat steps 2) and 3) until done.
  68.         5) set the display mode back to alpha.
  69.  
  70.     The graphics routines are accessed through software interrupt 5F (hex).
  71.     The required arguments are loaded into specific CPU registers, the
  72.     requested function number is loaded into the AH register, and then an
  73.     INT 5Fh instruction is executed.  Unless otherwise stated, all
  74.     functions preserve ALL registers except for AX.
  75.  
  76.     X-coordinates always get larger (more positive) when moving to the
  77.     right on the display.  Y-coordinates always get larger when moving
  78.     down (towards the bottom) on the display.  The default origin is in
  79.     the top-left corner of the display.
  80.  
  81.     Although the interface is designed primarily as an assembly language
  82.     interface, it is simple to write an assembly language module that can
  83.     provide a library of corresponding functions to a C program.  A sample
  84.     is provided in Appendix A.
  85.          ______________
  86.         SET VIDEO MODE
  87.  
  88.     Forces the current video mode to alpha or graphics and clears the
  89.     display.
  90.  
  91.     Entry conditions:
  92.  
  93.         AH = 0
  94.         AL = requested mode.
  95.             07h = alpha (system manager compliant)
  96.             20h = graphics (system manager compliant)
  97.             87h = alpha (non-system manager)
  98.             A0h = graphics (non-system manager)
  99.  
  100.     Sub-functions 07h and 20h call the System Manager routine to change
  101.     video modes, thus letting the System Manager know that the display has
  102.     changed modes and the display contents destroyed.  This is important
  103.     for any applications which are intended to be system manager compliant.
  104.  
  105.     Sub-functions 87h and A0h call the BIOS directly in order to change
  106.     display modes, thus by-passing the System Manager.  These should be
  107.     used by programs that are NOT System Manager compliant, so that they
  108.     will function correctly whether the system was booted into the System
  109.     Manager or if it was booted straight into DOS (by placing a SHELL=
  110.     command in a CONFIG.SYS file).
  111.  
  112.     After a SET_MODE call to change to graphics, the defaults are:
  113.  
  114.         Logical origin        (0, 0)
  115.         Clip region        (0, 0) thru (239, 127)
  116.         Pen location        (0, 0)
  117.         Pen color        1
  118.         Replacement rule    FORCE
  119.         Line-type        0FFFFh
  120.         Fill mask        0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
  121.  
  122.     Sample assembly code:
  123.  
  124.         mov    ax,0020h    ; set mode to GRAPHICS
  125.         int    5fh
  126.             .
  127.             .
  128.             .
  129.         mov    ax,0007h    ; set mode to ALPHA
  130.         int    5fh
  131.  
  132.          _____________
  133.         SET FILL MASK
  134.  
  135.     Sets the eight-byte fill mask used by DRAW_RECTANGLE when pattern-
  136.     filling.
  137.  
  138.     Entry conditions:
  139.  
  140.         AH = 1
  141.         ES:DI = address of 8 bytes of fillmask.
  142.  
  143.     The default fillmask after a mode set to graphics is eight bytes of
  144.     0ffh (which would result in a solid-fill).
  145.  
  146.     The fillmask is always aligned with the byte boundaries of the display
  147.     memory, and it is then clipped by the rectangle being drawn.  This
  148.     means that as the rectangle is shifted bit-by-bit, the pattern appears
  149.     to exist on a plane behind the rectangle, and that the rectangle is
  150.     a moving window onto that plane.  It's tough to describe, and a little
  151.     experimentation should make it plain.
  152.  
  153.     Sample assembly code:
  154.  
  155.         fmask1    db    055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
  156.             .
  157.             .
  158.             .
  159.         assume    es:dgroup
  160.         lea    di,fmask1
  161.         mov    ah,1
  162.         int    5fh        ; set fillmask pattern to FMASK1
  163.  
  164.          ________________________________
  165.         GET CURRENT GRAPHICS INFORMATION
  166.  
  167.     Returns current information about the state of the graphics functions.
  168.  
  169.     At entry:
  170.  
  171.         AH = 2
  172.         ES:DI = address of a 36-byte long buffer into which the
  173.             graphics information will be placed.  At exit from
  174.             this function, the buffer contents will be:
  175.  
  176.               offset  size
  177.              0   1-byte CURRENT VIDEO MODE
  178.              1   1-byte DEFAULT VIDEO MODE
  179.              2   1-word WIDTH OF DISPLAY IN PIXELS
  180.              4   1-word HEIGHT OF DISPLAY IN PIXELS
  181.              6   1-word CURRENT X-LOCATION OF PEN
  182.              8   1-word CURRENT Y-LOCATION OF PEN
  183.             10   1-word CURRENT LINE-TYPE
  184.             12   1-word CURRENT REPLACEMENT RULE
  185.             14   1-word CURRENT PEN COLOR
  186.             16   1-word CURRENT X-MINIMUM OF CLIP REGION
  187.             18   1-word CURRENT X-MAXIMUM OF CLIP REGION
  188.             20   1-word CURRENT Y-MINIMUM OF CLIP REGION
  189.             22   1-word CURRENT Y-MAXIMUM OF CLIP REGION
  190.             24   1-word CURRENT X-LOCATION OF LOGICAL ORIGIN
  191.             26   1-word CURRENT Y-LOCATION OF LOGICAL ORIGIN
  192.               28-35  8-bytes CURRENT FILL MASK (for rectangle fill)
  193.  
  194.     At exit:
  195.         DX:AX = address of the 36-byte long buffer (for return to C).
  196.  
  197.     Sample assembly code:
  198.  
  199.         infobuf        label    byte
  200.         curmode        db    ?
  201.         defmode        db    ?
  202.         dspwidth    dw    ?
  203.         dspheight    dw    ?
  204.         curpenx        dw    ?
  205.         curpeny        dw    ?
  206.         curlinetype    dw    ?
  207.         curreprule    dw    ?
  208.         curpen        dw    ?
  209.         curclipminx    dw    ?
  210.         curclipmaxx    dw    ?
  211.         curclipminy    dw    ?
  212.         curclipmaxy    dw    ?
  213.         curlogorgx    dw    ?
  214.         curlogorgy    dw    ?
  215.         curfmask    db    8 dup (?)
  216.                 .
  217.                 .
  218.                 .
  219.         assume    es:dgroup
  220.         lea    di,infobuf
  221.         mov    ah,2        ; read current video info into infobuf
  222.         int    5fh
  223.          __________________
  224.         SET LOGICAL ORIGIN
  225.  
  226.     Sets the logical origin in terms of absolute screen pixels, regardless
  227.     of previous settings of the logical origin or clip region.  The (X,Y)
  228.     of the logical origin may be specified off of the actual physical
  229.     screen (ie, negative values or greater than (239, 127).  All other
  230.     coordinate arguments in this graphics system are relative to the
  231.     logical origin, including those used to specify the clip region.
  232.  
  233.     SET LOGICAL ORIGIN resets the CLIP REGION to the entire physical
  234.     display (0,0) to (239,127).  So, if clip_region is used, it must be
  235.     set AFTER the set_logical_origin.
  236.  
  237.     The default logical origin after a mode set is (0,0).
  238.  
  239.     At entry:
  240.  
  241.         AH = 3
  242.         CX = x coordinate
  243.         DX = y coordinate
  244.  
  245.     Sample assembly code:
  246.  
  247.         mov    ah,3
  248.         mov    cx,120        ; move log org to approximately the
  249.         mov    dx,64        ;   center of the display
  250.         int    5fh
  251.  
  252.     _______________
  253.     SET CLIP REGION
  254.  
  255.     This function sets the coordinates of the upper-left and lower-right
  256.     corners of the clip rectangle.
  257.  
  258.     All reading/writing of the display in this graphics system is limited
  259.     (clipped) by the current CLIP REGION.
  260.  
  261.     Default after mode set is (0,0) and (239,127).
  262.  
  263.     At entry:
  264.  
  265.         AH = 4 
  266.         CX = x-minimum coordinate
  267.         DX = y-minimum coordinate
  268.         SI = x-maximum coordinate
  269.         DI = y-maximum coordinate
  270.  
  271.     Sample assembly code:
  272.  
  273.         mov    ah,4        ; clip (limit) all drawing to the
  274.         mov    cx,120        ;    right half of the display
  275.         mov    dx,0
  276.         mov    si,239
  277.         mov    dx,127
  278.         int    5fh
  279.  
  280.          ______________
  281.         DRAW RECTANGLE
  282.  
  283.     This draws a rectangle which has two diagonally opposite corners at
  284.     the current pen location and (CX,DX).  Hence, you will usually first
  285.     do a MOVE_PEN, then a DRAW_RECTANGLE.  ALL rectangle draws obey the
  286.     current replacement rule.  The pen location is left at the starting
  287.     location (it is not changed).
  288.  
  289.     If the rectangle drawn is just an outline, it is drawn using the
  290.     current line-type.  If the rectangle drawn is pattern-filled, it uses
  291.     the current fill-mask.  In all cases the current pen color and replace-
  292.     ment rule are used.
  293.  
  294.     At entry:
  295.         AH = 5
  296.         AL = fill flag    0==outline, current linetype and pen color
  297.                 1==solid fill, current pen color
  298.                 2==pattern fill, current fillmask and pen color
  299.         CX = x-coordinate of second corner of rectangle
  300.         DX = y-coordinate of second corner of rectangle
  301.  
  302.     Sample assembly code:
  303.  
  304.         mov    ah,8        ; move pen to (50,74)
  305.         mov    cx,50
  306.         mov    dx,74
  307.         int    5fh
  308.  
  309.         mov    ah,5
  310.         mov    al,1        ; solidfill rectangle to (101, 99)
  311.         mov    cx,101
  312.         mov    dx,99
  313.         int    5fh
  314.  
  315.     _________
  316.     DRAW LINE
  317.  
  318.     This draws a line from the current pen location to (CX,DX) using the
  319.     current pen color, linetype, and replacement rule.  The pen location
  320.     is left at the end point.  If another DRAW_LINE is executed after the
  321.     first without an intervening MOVE_PEN, the starting point is not
  322.     plotted.  This is to avoid the problem of drawing connecting lines
  323.     with a replacement rule of XOR.  Since the starting point of the second
  324.     line is the same as the ending point of the first line, it would get
  325.     plotted twice, which in XOR mode is the same as not plotting it at all.
  326.  
  327.     At entry:
  328.  
  329.         AH = 6
  330.         CX = x-coordinate of end point
  331.         DX = y-coordinate of end point
  332.  
  333.     Sample assembly code:
  334.  
  335.         mov    ah,6
  336.         mov    cx,21
  337.         mov    dx,10        ; draw from current pen location
  338.         int    5fh        ;   to (21, 10)
  339.          __________
  340.         PLOT POINT
  341.  
  342.     This moves the current pen location to CX,DX and plots a single
  343.     point there using the current pen color and replacement rule.
  344.  
  345.     At entry:
  346.  
  347.         AH = 7
  348.         CX = x-coordinate of point
  349.         DX = y-coordinate of point
  350.  
  351.     Sample assembly code:
  352.  
  353.         mov    ah,7
  354.         mov    cx,239        ; plot point at (239, 127)
  355.         mov    dx,127
  356.         int    5fh
  357.  
  358.     ________
  359.     MOVE PEN
  360.  
  361.     This moves the current pen location to (CX,DX).  The default location
  362.     after a mode set is (0,0).
  363.  
  364.     At entry:
  365.  
  366.         AH = 8
  367.         CX = x-coordinate
  368.         DX = y-coordinate
  369.  
  370.     Sample assembly code:
  371.  
  372.         mov    ah,8
  373.         mov    cx,22        ; move pen to (22, 44)
  374.         mov    dx,44
  375.         int    5fh
  376.  
  377.     _____________
  378.     SET PEN COLOR
  379.  
  380.     Sets the current pen color to 0 or 1.  The default after a mode
  381.     set is 1 (black).
  382.  
  383.     At entry:
  384.  
  385.         AH = 9
  386.         AL = new pen color (0 for white or 1 for black)
  387.  
  388.     Sample assembly code:
  389.  
  390.         mov    ah,9
  391.         mov    al,0        ; set pen color to white (0)
  392.         int    5fh
  393.  
  394.          ____________________
  395.         SET REPLACEMENT RULE
  396.  
  397.     The replacement rule controls how the current pen color is combined
  398.     with the existing color of a pixel on the display when performing
  399.     any plotting function (except WRITE_AREA, which has its own replacement
  400.     rule specified with each call).  If the current replacement rule is
  401.     FORCE then the resulting color of a pixel is equal to the current pen
  402.     color at the time of the plotting action.  For the other three replace-
  403.     ment rules (AND, OR, and XOR), the resulting color is the logical
  404.     operation between the current screen pixel color and the current pen
  405.     color.
  406.  
  407.     The default replacement rule after a mode set is 0 (FORCE).
  408.  
  409.     At entry:
  410.  
  411.         AH = 10 (0Ah)
  412.         AL = new replacement rule    0==FORCE
  413.                         1==AND
  414.                         2==OR
  415.                         3==XOR
  416.     Sample assembly code:
  417.  
  418.         mov    ah,10
  419.         mov    al,3        ; set replacement rule to XOR
  420.         int    5fh
  421.  
  422.     _____________
  423.     SET LINE TYPE
  424.  
  425.     This is a 16-bit value that is repeated over and over as each pixel
  426.     of a line or an outlined rectangle is drawn.  0xFFFF will cause solid
  427.     lines to be drawn. The default after a mode set is 0xFFFF (solid line).
  428.  
  429.     At entry:
  430.  
  431.         AH = 11 (0Bh)
  432.         CX = new line type
  433.  
  434.     Sample assembly code:
  435.  
  436.         mov    ah,11
  437.         mov    cx,0c440h    ; set line type to XX000X000X000000
  438.         int    5fh
  439.  
  440.          __________
  441.         READ POINT
  442.  
  443.     This returns AX==the color (0 for white, 1 for black) of the requested
  444.     point.  The current pen location is not modified.
  445.  
  446.     At entry:
  447.  
  448.         AH = 12 (0Ch)
  449.         CX = x-location of point to read
  450.         DX = y-location of point to read
  451.  
  452.     Sample assembly code:
  453.  
  454.         mov    ah,12
  455.         mov    cx,49        ; read point (49,57)
  456.         mov    dx,57
  457.         int    5fh
  458.  
  459.     _____________________
  460.     READ AREA (get image)
  461.  
  462.     This reads a rectangular area of the display into the specified
  463.     buffer.  There is an 8-byte header at the beginning (specifying
  464.     number of planes, number of bits/pixel, width of image, and
  465.     height of image.  The first two are always equal to 1 on the HP 95LX.
  466.     The size needed for the buffer is:
  467.  
  468.             8 + ((x2-x1+8)/8) * (y2-y1+1) bytes
  469.  
  470.     The diagonally opposite corner points (x1, y1) and (x2, y2) are
  471.     included in the read area.  Bits with a value of 0 are added to
  472.     the right end of each row of pixels (if necessary) to fill out an
  473.     integral number of bytes of data for that row.  The image is always
  474.     left justified within the buffer regardless of its byte-alignment on
  475.     the display.
  476.  
  477.     At entry:
  478.  
  479.         AH = 13 (0Dh)
  480.         CX = x-coordinate of corner 1
  481.         DX = y-coordinate of corner 1
  482.         SI = x-coordinate of corner 2
  483.         BP = y-coordinate of corner 2
  484.         ES:DI = address of buffer for image
  485.  
  486.     Sample assembly code:
  487.  
  488.         tmpbuf    db    56 dup (?)
  489.         .
  490.         .
  491.         .
  492.         assume    es:dgroup
  493.         mov    ah,13
  494.         mov    cx,24
  495.         mov    dx,55
  496.         mov    si,41        ; read a rectangular area of the screen
  497.         mov    bp,70        ;   from (24,55) thru (41,70) into
  498.         lea    di,tmpbuf    ;   'tmpbuf'.
  499.         int    5fh
  500.          ______________________
  501.         WRITE AREA (put image)
  502.  
  503.     This writes to a rectangular area of the display from a specified
  504.     buffer.  The buffer should have the same eight-byte header described in     READ_AREA (above).  This call is different from all other "write"-type
  505.     calls in that it specifies its own replacement rule rather than using
  506.     the "current" replacement rule.  It expands upon the replacement
  507.     rule types by allowing the image to be inverted before being combined
  508.     in the usual fashion (according to FORCE, AND, OR, or XOR) with the
  509.     display contents.  This does not modify the contents of the buffer.
  510.  
  511.     If the entire image doesn't fit on the display, none of it is drawn.
  512.  
  513.     At entry:
  514.  
  515.         AH = 14 (0Eh)
  516.         AL = replacement rule    0 FORCE
  517.                     1 AND
  518.                     2 OR
  519.                     3 XOR
  520.                     4 invert image and then FORCE
  521.                     5 invert image and then AND
  522.                     6 invert image and then OR
  523.                     7 invert image and then XOR
  524.         CX = x-location of top-left corner of image destination
  525.         DX = y-location of top-left corner of image destination
  526.         ES:DI = address of image
  527.  
  528.     Sample assembly code:
  529.  
  530.         tmpbuf    db    56 dup (?)
  531.         .
  532.         .
  533.         .
  534.         assume    es:dgroup
  535.         mov    ah,14
  536.         mov    al,7        ; invert, then XOR
  537.         mov    cx,133
  538.         mov    dx,66
  539.         lea    di,tmpbuf    ; put image 'tmpbuf' at (133,66)
  540.  
  541.          __________
  542.         WRITE TEXT
  543.  
  544.     Writes the specified text (all 256 chars are legal EXCEPT 0)
  545.     to the specified location, horizontally or rotated 90 degrees
  546.     counter-clockwise from horizontal, using the BIOS 6x8 font, the
  547.     current pen color and replacement rule. The specified location (CX, DX)
  548.     is the top-left corner of the text string, or if the rotate flag
  549.     is non-zero, the string is rotated 90 degrees counterclockwise about
  550.     the point (CX, DX) (such that it is now the bottom-left corner of the
  551.     text).
  552.  
  553.     At entry:
  554.  
  555.         AH = 15 (0Fh)
  556.         AL = rotate flag.
  557.         CX = x-coordinate of top-left corner of first character
  558.         DX = y-coordinate of top-left corner of first character
  559.         ES:DI = address of null-terminated string
  560.  
  561.     Sample assembly code:
  562.  
  563.         txtstr    db    "This is a test",0
  564.         .
  565.         .
  566.         .
  567.         assume    es:dgroup
  568.         mov    ah,15
  569.         mov    al,0        ; plot text horizontally
  570.         mov    cx,124
  571.         mov    dx,37        ; at (124, 37)
  572.         lea    di,txtstr
  573.         int    5fh
  574.  
  575.          ___________________________________________________________________
  576.          APPENDIX A: Sample assembly language module of C-callable functions
  577.  
  578. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  579. ;[ Graphics interface module for calling Jaguar graphics from C programs [
  580. ;[ Copyright 1990 Hewlett Packard Company.  All rights reserved.     [
  581. ;[ Author: Everett Kaser  August 14, 1990.                 [
  582. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  583.  
  584.     .MODEL    LARGE,C
  585.  
  586.     .CODE
  587.     assume    ds:nothing
  588.  
  589. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  590. ; G_Mode(int BiosVideoMode);
  591. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  592.  
  593. G_Mode        PROC    BiosVideoMode:word
  594.     mov    ax,BiosVideoMode
  595.     xor    ah,ah
  596.     int    5fh
  597.     ret
  598. G_Mode        endp
  599.  
  600. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  601. ; G_FillMask(maskptr);
  602. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  603.  
  604. G_FillMask    PROC    uses ES DI, maskptr:dword
  605.     les    di,maskptr
  606.     mov    ah,1
  607.     int    5fh
  608.     ret
  609. G_FillMask    endp
  610.  
  611. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  612. ; G_GetInfo(G_INFO *gp);
  613. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  614.  
  615. G_GetInfo    PROC    uses ES DI, gp:dword
  616.     les    di,gp
  617.     mov    ah,2
  618.     int    5fh
  619.     ret
  620. G_GetInfo    endp
  621.  
  622. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  623. ; G_LorgA(int x, int y);
  624. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  625.  
  626. G_LorgA        PROC    x:word, y:word
  627.     mov    cx,x
  628.     mov    dx,y
  629.     mov    ah,3
  630.     int    5fh
  631.     ret
  632. G_LorgA        endp
  633.  
  634. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  635. ; G_ClipL(int xmin, int ymin, int xmax, int ymax);
  636. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  637.  
  638. G_ClipL        PROC    uses SI DI, xmin:word, ymin:word, xmax:word, ymax:word
  639.     mov    cx,xmin
  640.     mov    dx,ymin
  641.     mov    si,xmax
  642.     mov    di,ymax
  643.     mov    ah,4
  644.     int    5fh
  645.     ret
  646. G_ClipL        endp
  647.  
  648. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  649. ; G_Rect(int x, int y, int fillflag);
  650. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  651.  
  652. G_Rect        PROC    x:word, y:word, fill:word
  653.     mov    cx,x
  654.     mov    dx,y
  655.     mov    ax,fill
  656.     mov    ah,5
  657.     int    5fh
  658.     ret
  659. G_Rect        endp
  660.  
  661. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  662. ; G_Draw(int x, int y);
  663. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  664.  
  665. G_Draw        PROC    x:word, y:word
  666.     mov    cx,x
  667.     mov    dx,y
  668.     mov    ah,6
  669.     int    5fh
  670.     ret
  671. G_Draw        endp
  672.  
  673. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  674. ; G_Point(int x, int y);
  675. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  676.  
  677. G_Point        PROC    x:word, y:word
  678.     mov    cx,x
  679.     mov    dx,y
  680.     mov    ah,7
  681.     int    5fh
  682.     ret
  683. G_Point        endp
  684.  
  685. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  686. ; G_Move(int x, int y);
  687. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  688.  
  689. G_Move        PROC    x:word, y:word
  690.     mov    cx,x
  691.     mov    dx,y
  692.     mov    ah,8
  693.     int    5fh
  694.     ret
  695. G_Move        endp
  696.  
  697. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  698. ; G_ColorSel(int color);
  699. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  700.  
  701. G_ColorSel    PROC    color:word
  702.     mov    ax,color
  703.     mov    ah,9
  704.     int    5fh
  705.     ret
  706. G_ColorSel    endp
  707.  
  708. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  709. ; G_RepRule(int rrule);
  710. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  711.  
  712. G_RepRule    PROC    rrule:word
  713.     mov    ax,rrule
  714.     mov    ah,0ah
  715.     int    5fh
  716.     ret
  717. G_RepRule    endp
  718.  
  719. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  720. ; G_LineType(int ltype);
  721. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  722.  
  723. G_LineType    PROC    ltype:word
  724.     mov    cx,ltype
  725.     mov    ah,0bh
  726.     int    5fh
  727.     ret
  728. G_LineType    endp
  729.  
  730. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  731. ; G_PointRead(int x, int y);
  732. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  733.  
  734. G_PointRead    PROC    x:word, y:word
  735.     mov    cx,x
  736.     mov    dx,y
  737.     mov    ah,0ch
  738.     int    5fh
  739.     ret
  740. G_PointRead    endp
  741.  
  742. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  743. ; G_ImageGet(int x1, int y1, int x2, int y2, char far *image);
  744. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  745.  
  746. G_ImageGet    PROC    uses ES SI DI, x1:word, y1:word, x2:word, y2:word, image:dword
  747.     mov    cx,x1
  748.     mov    dx,y1
  749.     mov    si,x2
  750.     les    di,image
  751.     mov    bp,y2
  752.     mov    ah,0dh
  753.     int    5fh
  754.     ret
  755. G_ImageGet    endp
  756.  
  757. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  758. ; G_ImagePut(int x, int y, char far *image, int replacerule);
  759. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  760.  
  761. G_ImagePut    PROC    uses ES DI, x:word, y:word, image:dword, reprule:word
  762.     mov    cx,x
  763.     mov    dx,y
  764.     les    di,image
  765.     mov    ax,reprule
  766.     mov    ah,0eh
  767.     int    5fh
  768.     ret
  769. G_ImagePut    endp
  770.  
  771. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  772. ; G_Text(int x, int y, char far *string, rotflag);
  773. ;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  774.  
  775. G_Text        PROC    uses DS ES SI DI, x:word, y:word, string:dword, rotflag:word
  776.     mov    ax,rotflag
  777.     mov    cx,x
  778.     mov    dx,y
  779.     les    di,string
  780.     mov    ah,0fh
  781.     int    5fh
  782.     ret
  783. G_Text        endp
  784.  
  785. @curseg    ends
  786.     end
  787.          ______________________________________________________________________
  788.          APPENDIX B: Sample header file for use with C programs and APPENDIX A.
  789.  
  790. /*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  791.   [ Definitions.                            [
  792.   [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[*/
  793.  
  794. #define    G_ALPHA        0x07
  795. #define    G_GRAPHICS    0x20
  796.  
  797. #define    G_FORCE        0
  798. #define    G_AND        1
  799. #define    G_OR        2
  800. #define    G_XOR        3
  801. #define    G_NOTFORCE    4
  802. #define    G_NOTAND    5
  803. #define    G_NOTOR        6
  804. #define    G_NOTXOR    7
  805.  
  806. #define    G_OUTLINE    0
  807. #define    G_SOLIDFILL    1
  808. #define    G_PATTERNFILL    2
  809.  
  810. #define    MINCOLOR    0
  811. #define    MAXCOLOR    1
  812.  
  813. /*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  814.   [ Structures.                                [
  815.   [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[*/
  816.  
  817. typedef    struct g_info {
  818.     unsigned char    vidmode;
  819.     unsigned char    defmode;
  820.     unsigned int    xpixels;
  821.     unsigned int    ypixels;
  822.     int        xloc;
  823.     int        yloc;
  824.     unsigned int    linetype;
  825.     int        rrule;
  826.     unsigned int    color;
  827.     int        xclipmin;
  828.     int        yclipmin;
  829.     int        xclipmax;
  830.     int        yclipmax;
  831.     int        xlorg;
  832.     int        ylorg;
  833.     unsigned char    fillmask[8];
  834.     } G_INFO;
  835.  
  836. /*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  837.   [ Graphics library function definitions.  All x,y locations are rel-  [
  838.   [   ative to the current logical origin unless specified otherwise.    [
  839.   [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[*/
  840. void   far cdecl    G_Mode(int);
  841. G_INFO far * cdecl    G_GetInfo(G_INFO far *);
  842. void   far cdecl    G_ColorSel(int);
  843. void   far cdecl    G_RepRule(unsigned int);
  844. void   far cdecl    G_LineType(unsigned int);
  845. void   far cdecl    G_FillMask(unsigned char far *);
  846. void   far cdecl    G_LorgA(int, int);
  847. void   far cdecl    G_ClipL(int, int, int, int);
  848. void   far cdecl    G_Move(int, int);
  849. void   far cdecl    G_Point(int, int);
  850. int    far cdecl    G_PointRead(int, int);
  851. void   far cdecl    G_Draw(int, int);
  852. void   far cdecl    G_Rect(int, int, int);
  853. void   far cdecl    G_ImageGet(int, int, int, int, char far *);
  854. void   far cdecl    G_ImagePut(int, int, char far *, int);
  855. void   far cdecl    G_Text(int, int, char far *, int);
  856.  
  857. /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  858.  
  859. /**** G_MODE(mode): mode = {G_TEXT | G_GRAPHICS}
  860.     changes the display mode to text or graphics        */
  861.  
  862. /**** G_GETINFO(GraphInfoPtr): GraphInfoPtr is a far pointer to a buffer of
  863.     the programmers choosing where the graphics information will be copied.
  864.     See the typedef for the G_INFO structure in this file for the contents
  865.     of the buffer.    */
  866. /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  867.  
  868. /**** G_COLORSEL(color): color = 0 or 1
  869.     sets the current pen to "color"                */
  870.  
  871. /**** G_REPRULE(reprule): reprule = {G_FORCE | G_AND | G_OR | G_XOR}
  872.     sets the current replacement rule for all other drawing (except for
  873.     G_ImagePut, which specifies its own replacement rule). */
  874.  
  875. /**** G_LINETYPE(linetype): linetype = a 16-bit image that is repeated while
  876.     drawing lines and G_OUTLINE'd rectangles.  Bits that are 1 cause the
  877.     current pen color to be plotted using the current replacement rule.
  878.     Bits that are 0 are not plotted and leave the display un-modified. */
  879.  
  880. /**** G_FILLMASK(buffer): buffer is a far pointer to an 8-byte array which
  881.     specifies the fillmask to use when doing drawings of rectangles
  882.     with a fillflag of G_PATTERNFILL.  Every bit that is a 1 will
  883.     cause a point of the current color to be plotted.  Every bit that is
  884.     a 0 will cause that "point" of the display to be undisturbed. */
  885. /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  886.  
  887. /**** G_LORGA(x,y): x,y = -32768 to +32767
  888.     sets the logical origin (0,0) to be located at the absolute screen
  889.     coordinate specified by x,y. */
  890.  
  891. /**** G_CLIPL(x1, y1, x2, y2): x1,y1,x2,y2 = -32768 to +32767
  892.     sets the current clip boundary to the rectangle whose diagonally
  893.     opposite corners are specified by the absolute screen coordinates
  894.     equal to the x1,y1 and x2,y2 offsets from the current logical origin.*/
  895.  /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  896.  
  897. /**** G_MOVE(x, y): x,y = -32768 to +32767
  898.     causes the logical pen to be moved to "x,y"        */
  899.  
  900. /**** G_POINT(x,y): x,y = -32768 to +32767
  901.     plots a point of the current pen color with the current replacement
  902.     rule at "x,y" unless "x,y" is outside the current clip limits    */
  903.  
  904. /**** G_POINTREAD(x,y): x,y = -32768 to +32767
  905.     reads the color of the point located at x,y and returns that as the
  906.     value of the function. */
  907.  
  908. /**** G_DRAW(x,y): x,y = -32768 to +32767
  909.     draws a line of the current pen color with the current replacement rule
  910.     and the current linetype from the current pen location to "x,y";
  911.     only those points lying within the clip limits are actually plotted. */
  912.  
  913. /**** G_RECT(x,y,fillflag): x,y = -32768 to +32767
  914.     fillflag = {G_OUTLINE | G_SOLIDFILL | G_PATTERNFILL}
  915.     draws a rectangle with diagonally opposite corners at the current pen
  916.     location and at "x,y", using the current pen color and replacement
  917.     rule.  The "type" of rectangle drawn is determined by fillflag.
  918.     if fillflag==G_OUTLINE, the outline of a rectangle is drawn, using the
  919.         current linetype.
  920.     if fillflag==G_SOLIDFILL, a solid, filled rectangle of the current
  921.         color is drawn.
  922.     if fillflag==G_PATTERNFILL, a pattern filled rectangle of the current
  923.         color is drawn, using the current fill mask.    */
  924. /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  925.  
  926. /**** G_IMAGEGET(x1, y1, x2, y2, buffer):  x1,y1,x2,y2 = -32768 to +32767
  927.     If both points x1,y1 and x2,y2 are within the current clip boundary,
  928.     the display image bounded by the rectangle whose diagonally opposite
  929.     corners are x1,y1 and x2,y2 is read into the bytes pointed to by
  930.     "buffer". */
  931.  
  932.    NOTE: for G_ImageGet(), the required size of 'buffer' is (on Jaguar):
  933.  
  934.     8 + ((x2-x1+8)/8) * (y2-y1+1) bytes          */
  935.  
  936. /**** G_IMAGEPUT(x, y, buffer, reprule): x,y = -32768 to +32767
  937.     reprule = {G_FORCE | G_AND | G_OR | G_XOR | G_NOTFORCE | G_NOTAND |
  938.             G_NOTOR | G_NOTXOR}
  939.     if x,y and the un-specified bottom-right corner of the image are
  940.     within the clip boundary, the image from "buffer" is drawn on the
  941.     display using reprule as the replacement rule.  (For the "NOT" replace-
  942.     ment rules, the image is color-inverted first, then placed on the
  943.     display using the "rest" of the replacement rule.) */
  944. /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  945.  
  946. /**** G_TEXT(x,y,buffer,rotflag): x,y = -32768 to +32767, rotflag = 0 or 1
  947.     draws the string pointed to by "buffer" on the display at the specified
  948.     location x,y using the current font. If rotflag = 0, it's drawn
  949.     horizontally, else it's rotated 90 degrees counterclockwise. */
  950. /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  951.